package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.handler.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQueryParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceSaveParam;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "电子围栏管理")
@RequestMapping("/v1/geofence")
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;
    @GetMapping("/select")
    @ApiOperation(value = "查询电子围栏信息")
    public JsonResult selectGeofence (GeofenceQueryParam geofenceQuery){
        log.debug("查询电子围栏信息:geofenceQuery={}",geofenceQuery);
        List<GeofenceVO>list=geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult saveGeoFence(GeofenceSaveParam geofenceParam){
        log.debug("保存电子围栏数据：geofenceParam{}",geofenceParam);
    geofenceService.saveGeofence(geofenceParam);
    return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id) {
        log.debug("删除电子围栏:id={}", id);
        geofenceService.deleteGeofence(id);
        return JsonResult.ok();

    }
    }
